package com.zhu.fastFoodRestaurantOrderSystem.exception;

public enum ErrorCode {
    ORDER_ITEM_INVALID("ORDER_001", "订单商品无效"),
    ORDER_ITEM_LIMIT_EXCEEDED("ORDER_002", "单笔订单最多包含5个商品项"),
    ORDER_NO_MAIN_ITEM("ORDER_003", "每个订单必须包含至少一个主食"),
    ORDER_DESSERT_WITHOUT_MAIN("ORDER_004", "甜品不能单独购买（必须搭配主食）"),
    ORDER_ICE_COFFEE_AFTER_3PM("ORDER_005", "冰咖啡在下午3点后不能售卖"),
    ORDER_CANCELLED("ORDER_006", "订单已被取消"),
    ORDER_PAID("ORDER_007", "订单已被支付"),
    ORDER_NOT_FOUND("ORDER_007", "订单不存在"),
    ORDER_NOT_CREATABLE("ORDER_008", "订单创建失败"),
    ORDER_STATUS_INVALID("ORDER_009", "订单状态无效"),
    ORDER_CANCEL_TIMEOUT("ORDER_010", "订单创建超过30分钟，已自动取消"),
    ORDER_STATUS_INVALID_TRANSITION("ORDER_011", "订单状态转换无效"),
    ORDER_ONLY_DRINKS("ORDER_012", "订单不能仅包含饮料"),
    ITEM_OUT_OF_STOCK("ITEM_001", "商品 %s 库存不足"),
    ORDER_STATUS_ANOMALY("ORDER_013", "订单状态异常");


    private final String code;
    private final String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String getFormattedMessage(String... args) {
        return String.format(message, args);
    }
}